<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>客户签名列表</title>
    <!-- css代码 start -->
    <link href="../../../../css/mui.min.css" rel="stylesheet"/>
    <link href="../../../../css/global.css" rel="stylesheet"/>
    <link href="../../../../css/style.css" rel="stylesheet"/>
    <link href="../../../../css/task.css" rel="stylesheet"/>
    <style>
        #div {
            width: 0px;
            height: 0px;
            background: red;
            position: fixed;
            top: 65%;
            left: 50%;
        }

        /*移除底部或顶部三角,需要在删除此代码*/
        .mui-popover .mui-popover-arrow:after {
            width: 0px;
        }

        .mui-checkbox input[type=checkbox], .mui-radio input[type=radio] {
            top: 8px;
            right: -10px;
        }

        .details_con {
            background: #fff;
        }

        input.d_ipt {
            width: 60%;
            background: #fff;
        }

        .mui-btn-block {
            border: 0;
            font-size: 16px;
            color: #a9a9a9;
        }

        .lpl {
            width: 80px !important;
        }

        .item_box .item .bar .yulan {
            color: #ea1e1a;
            background: url(../../../../images/icon_367.png) no-repeat left center;
            background-size: 21px 13px;
        }

    </style>
    <!-- css代码 end -->
</head>
<body>

<div id="div"></div>
<div id="popover" class="mui-popover shadow popover">
    <p id="closeTitle" class="title">确定要关闭服务？</p>
    <div class="btn_box">
        <span class="fl" onclick="closepop()">取消</span>
        <span class="fr red" id="quedingupdate">确定</span>
    </div>
</div>

<!-- html代码 start -->
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 id="title" class="mui-title">客户签名列表</h1>
</header>
<div class="mui-content">
    <div class="page_cen shadow title_num" id="dianji">服务通知编号：<span id="serviceNo" style="color: #ea1e1a;"></span></div>
    <div class="item_box" id="itemBox">
        <!-- <div class="item">
        <div class="bar">
            <span class="yulan" onclick="preview(' + info.serviceNo + ',' + info.relServiceNo + ',' + info.id +
                ',' + info.reportNo + ')">预览</span>
        <span class="number">173<img src="../../../../images/icon_204.png" /></span>
        </div>
        <div class="type">
        <p><div class="lpl">FSE：</div><span>测试-叶2</span><img src="../../../../images/icon_219.png"/></p>
        <p><div class="lpl">客户名称：</div><span>内蒙古伊利实业集团股份有限公司</span><img src="../../../../images/icon_201.png"/></p>
        <p><div class="lpl">报告类型：</div><span>服务报告</span><img src="../../../../images/icon_203.png"/></p>
        <p><div class="lpl">仪器型号：</div><span>ICE 3500</span><img src="../../../../images/icon_217.png"/></p>
        </div>
        </div> -->
    </div>
    <div class="btn_box">
        <span class="fl red" id="gbym">关闭服务</span>
        <span class="fr red" id="khqm" style="display: none;">客户签名</span>
    </div>
</div>
<!-- html代码 end -->

<!-- js代码 start -->

<!-- 基础js start -->
<script src="../../../../js/mui.min.js"></script>
<script src="../../../../js/utils/h.js"></script>
<script src="../../../../js/constant.js"></script>
<script src="../../../../js/common.js"></script>
<script src="../../../../js/utils/base64.js"></script>
<script src="../../../../js/utils/md5.js"></script>
<script src="../../../../js/utils/sortMap.js"></script>
<script src="../../../../js/utils/http.js"></script>
<script src="../../../../js/app.js"></script>
<!-- 基础js end -->

<script type="text/javascript" charset="utf-8">

    var ServiceNoticeId;
    var serviceNo;
    var planId;
    var serviceType;
    var signInTime
    var longitude
    var latitude

    // 取消方法 关闭弹窗
    function closepop() {
        mui("#popover").popover('hide', document.getElementById("div"));
    }

    (function ($, doc) {

        $.init();

        $.plusReady(function () {
            var self = plus.webview.currentWebview();
            ServiceNoticeId = self.ServiceNoticeId;
            planId = self.planId;
            serviceNo = self.serviceNo;
            serviceType = self.serviceType;
            // console.log(ServiceNoticeId+"         "+planId+"         "+serviceNo)
            h('#serviceNo').html(serviceNo);
            
			app.showWaiting('加载中...');
            plus.geolocation.getCurrentPosition(function (p) {
                longitude = p.coords.longitude;
                latitude = p.coords.latitude;
				
				//获取签到时间
				findSignInTime();
				initData();
            }, function (e) {
                app.closeWaiting();
                app.toast("定位失败");
            }, {geocode: false});

            //关闭服务
            h('#gbym').tap(function () {
                app.showWaiting('正在提交...')
                if (serviceType && serviceType == '安装') {
                    // 安装单 验证核对仪器序列号是否一致
                    ajaxGet(BASE_URL + "cc/instrument/checkSerialNumberAndCaseByServiceNotice", {
                        "serviceNo": serviceNo
                    }, function (res) {
                        console.debug(res)
                        if (res.code == 200) {
                            if (res.data.ischecked == "1") {
                                // 一致
                                if (res.data.caseIsClosed == "1") {
                                    //无未完成的case
                                    h("#closeTitle").html('确定要关闭服务？')
                                    // 验证是否有未提交的报告
                                } else {
                                    //有未完成的case
                                    h("#closeTitle").html('您有升级的CASE未处理完成，是否确认关闭服务？')

                                }
                                ajaxGet(BASE_URL + "cc/report/info/checkReport", {
                                    "serviceNo": serviceNo,
                                    "syncFlag": "0"
                                }, function (data) {
                                    if (data.code === 200) {
                                        if (data.data != "") {
                                            app.closeWaiting()
                                            app.toast("存在未提交的报告，无法关闭服务");
                                            return
                                        } else {
                                            app.closeWaiting()
                                            // 调用弹窗
                                            mui("#popover").popover('toggle', document.getElementById("div"));
                                        }
                                    } else {
                                        app.closeWaiting()
                                        app.toast(data.msg)
                                    }
                                }, function (errorMsg) {
                                    app.closeWaiting()
                                    app.toast("关闭失败")
                                });

                            } else {
                                // 不一致
                                app.closeWaiting()
                                app.toast("请核对序列号信息是否一致")

                            }

                        } else {
                            app.closeWaiting()
                            app.toast(res.msg)
                        }
                    }, function (errorMsg) {
                        app.closeWaiting()
                        app.toast("关闭失败")
                        console.log(JSON.stringify(errorMsg))
                    });
                } else {
                    ajaxGet(BASE_URL + "cc/instrument/checkSerialNumberAndCaseByServiceNotice", {
                            "serviceNo": serviceNo
                        }, function (res) {
                            console.debug(res)
                            if (res.data.caseIsClosed == "1") {
                                //无未完成的case
                                h("#closeTitle").html('确定要关闭服务？')
                            } else {
                                //有未完成的case
                                h("#closeTitle").html('您有升级的CASE未处理完成，是否确认关闭服务？')

                            }
                            // 非安装单 验证是否有未提交的报告
                            ajaxGet(BASE_URL + "cc/report/info/checkReport", {
                                "serviceNo": serviceNo,
                                "syncFlag": "0"
                            }, function (data) {
                                if (data.code === 200) {
                                    if (data.data != "") {
                                        app.closeWaiting()
                                        app.toast("存在未提交的报告，无法关闭服务");
                                        return
                                    } else {
                                        app.closeWaiting()
                                        // 调用弹窗
                                        mui("#popover").popover('toggle', document.getElementById("div"));
                                    }
                                } else {
                                    app.closeWaiting()
                                    app.toast(data.msg)
                                }
                            }, function (errorMsg) {
                                app.closeWaiting()
                                app.toast("关闭失败")
                            });
                        },
                        function (errorMsg) {
                            app.closeWaiting()
                            app.toast("关闭失败")
                        }
                    )
                }
            })

            // 弹窗确定按钮
            h("#quedingupdate").tap(function () {
                guanbi()
            });

            // 跳转签名页面
            h("#khqm").tap(function () {
                app.jumpTo('/view/service/report/work/signature.html', 'view/service/report/work/signature.html', {
                    "serviceNoticeId": ServiceNoticeId,
                    "serviceNo": serviceNo
                })
            })
        });
    }(mui, document));

    /*function guanbi() {
        app.showWaiting('正在提交...')
        ajaxGet(BASE_URL + "cc/notice/closeNotice", {
            "enginnerId": app.getUser().enginnerId,
            "serviceNo": serviceNo,
            "serviceNoticeId": ServiceNoticeId,
        }, function(data) {
            app.closeWaiting()
            mui("#popover").popover('toggle', document.getElementById("div"));
            console.log(JSON.stringify(data))
            if (data.data.data.status === '1') {
                app.toast(data.msg)
                var maintenanceReport = plus.webview.getWebviewById('view/service/report/maintenanceReport.html');
                if (maintenanceReport) {
                    maintenanceReport.close()
                }

                var signOutAddReport = plus.webview.getWebviewById('view/service/notice/signOutAddReport.html');
                if (signOutAddReport) {
                    signOutAddReport.close()
                }

                var signInAddReport = plus.webview.getWebviewById('view/service/notice/signInAddReport.html');
                if (signInAddReport) {
                    signInAddReport.close()
                }

                var checkedInList = plus.webview.getWebviewById('view/service/notice/checkedInList.html');
                if (checkedInList) {
                    checkedInList.close()
                }

                // 1、刷新FSE首页
                var indexFSE = plus.webview.getWebviewById('view/main/indexFSE.html');
                if (indexFSE) {
                    indexFSE.evalJS('getList("1")')
                }

                // 2、刷新客户签名页（标题：服务通知列表 signWorkReportList）
                var indexFSE = plus.webview.getWebviewById('signWorkReportList');
                if (indexFSE) {
                    indexFSE.evalJS('initData()')
                }

                app.jumpTo('/view/service/notice/closedList.html', 'view/service/notice/closedList.html', {
                    ServiceNoticeId: ServiceNoticeId,
                    serviceNo: serviceNo,
                    planId: planId
                })
                var self = plus.webview.currentWebview();
                setTimeout(function () {
                    self.close()
                    var signOutVisitAgain = plus.webview.getWebviewById('view/service/notice/signOutVisitAgain.html');
                    signOutVisitAgain&&signOutVisitAgain.close()
                },500)

            } else {
                mui("#popover").popover('toggle', document.getElementById("div"));
                app.closeWaiting()
                app.toast(data.data.data.message)
            }

            /!*if(data.data.code == 205){
                var maintenanceReport = plus.webview.getWebviewById('view/service/report/maintenanceReport.html');
                if (maintenanceReport) {
                    maintenanceReport.close()
                }

                var signOutAddReport = plus.webview.getWebviewById('view/service/notice/signOutAddReport.html');
                if (signOutAddReport) {
                    signOutAddReport.close()
                }

                var signInAddReport = plus.webview.getWebviewById('view/service/notice/signInAddReport.html');
                if (signInAddReport) {
                    signInAddReport.close()
                }

                var checkedInList = plus.webview.getWebviewById('view/service/notice/checkedInList.html');
                if (checkedInList) {
                    checkedInList.close()
                }

                // 1、刷新FSE首页
                var indexFSE = plus.webview.getWebviewById('view/main/indexFSE.html');
                if (indexFSE) {
                    indexFSE.evalJS('getList("1")')
                }

                // 2、刷新客户签名页（标题：服务通知列表 signWorkReportList）
                var indexFSE = plus.webview.getWebviewById('signWorkReportList');
                if (indexFSE) {
                    indexFSE.evalJS('initData()')
                }


                app.jumpTo('/view/service/notice/signOutClose.html', 'view/service/notice/signOutClose.html', {
                    ServiceNoticeId: ServiceNoticeId,
                    serviceNo: serviceNo,
                    planId: planId,
                    serviceType: serviceType,
                    closeFlag:1
                })

                var self = plus.webview.currentWebview();
                setTimeout(function () {
                    self.close()
                    var signOutVisitAgain = plus.webview.getWebviewById('view/service/notice/signOutVisitAgain.html');
                    signOutVisitAgain&&signOutVisitAgain.close()
                },500)

            } else {
                if (data.data.data.status === '1') {
                    app.toast(data.msg)
                    var maintenanceReport = plus.webview.getWebviewById('view/service/report/maintenanceReport.html');
                    if (maintenanceReport) {
                        maintenanceReport.close()
                    }

                    var signOutAddReport = plus.webview.getWebviewById('view/service/notice/signOutAddReport.html');
                    if (signOutAddReport) {
                        signOutAddReport.close()
                    }

                    var signInAddReport = plus.webview.getWebviewById('view/service/notice/signInAddReport.html');
                    if (signInAddReport) {
                        signInAddReport.close()
                    }

                    var checkedInList = plus.webview.getWebviewById('view/service/notice/checkedInList.html');
                    if (checkedInList) {
                        checkedInList.close()
                    }

                    // 1、刷新FSE首页
                    var indexFSE = plus.webview.getWebviewById('view/main/indexFSE.html');
                    if (indexFSE) {
                        indexFSE.evalJS('getList("1")')
                    }

                    // 2、刷新客户签名页（标题：服务通知列表 signWorkReportList）
                    var indexFSE = plus.webview.getWebviewById('signWorkReportList');
                    if (indexFSE) {
                        indexFSE.evalJS('initData()')
                    }

                    // var closedList = plus.webview.getWebviewById('view/service/notice/closedList.html');
                    // if(closedList){
                    // 	closedList.evalJS('initData()')
                    // }
                    app.jumpTo('/view/service/notice/closedList.html', 'view/service/notice/closedList.html', {
                        ServiceNoticeId: ServiceNoticeId,
                        serviceNo: serviceNo,
                        planId: planId
                    })
                    // var closedList = plus.webview.getWebviewById('view/service/notice/signOutClose.html');
                    // if(closedList){
                    // 	closedList.evalJS('initData()')
                    // 	mui.back()
                    // }else{
                    // 	var self = plus.webview.currentWebview();
                    // 	var closedList1 = plus.webview.create('/view/service/notice/signOutClose.html','view/service/notice/signOutClose.html')
                    // 	closedList1.show()
                    // 	self.close()
                    // }
                    // app.jumpTo('/view/service/notice/signOutClose.html', 'view/service/notice/signOutClose.html', {
                    // 	ServiceNoticeId: ServiceNoticeId,
                    // 	serviceNo: serviceNo,
                    // 	planId: planId
                    // })
                    var self = plus.webview.currentWebview();
                    setTimeout(function () {
                        self.close()
                        var signOutVisitAgain = plus.webview.getWebviewById('view/service/notice/signOutVisitAgain.html');
                        signOutVisitAgain&&signOutVisitAgain.close()
                    },500)

                    // var closedList = plus.webview.getWebviewById('view/service/notice/closedList.html');
                    // if(closedList){
                    // 	closedList.evalJS('initData()')
                    // 	mui.back()
                    // }else{
                    // 	var self = plus.webview.currentWebview();
                    // 	var closedList1 = plus.webview.create('/view/service/notice/closedList.html','view/service/notice/closedList.html')
                    // 	closedList1.show()
                    // 	self.close()
                    // }
                    // app.jumpTo('/view/service/notice/closedList.html','view/service/notice/closedList.html')
                } else {
                    mui("#popover").popover('toggle', document.getElementById("div"));
                    app.closeWaiting()
                    app.toast(data.data.data.message)
                }
            }*!/
        }, function(errorMsg) {
            app.closeWaiting()
            app.toast("关闭失败")
        });
    }*/
    function guanbi() {
        /*console.log(
            {
                "enginnerId": app.getUser().enginnerId`,
                "serviceNo": serviceNo,
                "serviceNoticeId": ServiceNoticeId,
                "customerName": app.getUser().name,
                "signInTime": signInTime,
                "longitude": longitude,
                "latitude": latitude,
                "state": 4,
            }
        )
        return*/
        app.showWaiting('正在提交...')
        ajaxGet(BASE_URL + "cc/notice/closeNoticeAndSignoff", {
            "enginnerId": app.getUser().enginnerId,
            "serviceNo": serviceNo,
            "serviceNoticeId": ServiceNoticeId,
            "customerName": app.getUser().name,
            "signInTime": signInTime,
            "longitude": longitude,
            "latitude": latitude,
            "state": 4,
        }, function (data) {
            app.closeWaiting()
            mui("#popover").popover('toggle', document.getElementById("div"));
            console.log(JSON.stringify(data))
            if (data.data.code == 200) {
                app.toast(data.msg)
                var maintenanceReport = plus.webview.getWebviewById('view/service/report/maintenanceReport.html');
                if (maintenanceReport) {
                    maintenanceReport.close()
                }

                var signOutAddReport = plus.webview.getWebviewById('view/service/notice/signOutAddReport.html');
                if (signOutAddReport) {
                    signOutAddReport.close()
                }

                var signInAddReport = plus.webview.getWebviewById('view/service/notice/signInAddReport.html');
                if (signInAddReport) {
                    signInAddReport.close()
                }

                var checkedInList = plus.webview.getWebviewById('view/service/notice/checkedInList.html');
                if (checkedInList) {
                    checkedInList.close()
                }

                // 1、刷新FSE首页
                var indexFSE = plus.webview.getWebviewById('view/main/indexFSE.html');
                if (indexFSE) {
                    indexFSE.evalJS('getList("1")')
                }

                // 2、刷新客户签名页（标题：服务通知列表 signWorkReportList）
                var indexFSE = plus.webview.getWebviewById('signWorkReportList');
                if (indexFSE) {
                    indexFSE.evalJS('initData()')
                }

                app.jumpTo('/view/service/notice/closedList.html', 'view/service/notice/closedList.html', {
                    ServiceNoticeId: ServiceNoticeId,
                    serviceNo: serviceNo,
                    planId: planId
                })
                var self = plus.webview.currentWebview();
                self.close()
                var signOutVisitAgain = plus.webview.getWebviewById('view/service/notice/signOutVisitAgain.html');
                signOutVisitAgain && signOutVisitAgain.close()

            } else {
                /*mui("#popover").popover('toggle', document.getElementById("div"));
                app.closeWaiting()
*/
                console.log(data)
                data.data.data && app.toast(data.data.data.message)
                data.data.message && app.toast(data.data.message)
            }

            /*if(data.data.code == 205){
                var maintenanceReport = plus.webview.getWebviewById('view/service/report/maintenanceReport.html');
                if (maintenanceReport) {
                    maintenanceReport.close()
                }

                var signOutAddReport = plus.webview.getWebviewById('view/service/notice/signOutAddReport.html');
                if (signOutAddReport) {
                    signOutAddReport.close()
                }

                var signInAddReport = plus.webview.getWebviewById('view/service/notice/signInAddReport.html');
                if (signInAddReport) {
                    signInAddReport.close()
                }

                var checkedInList = plus.webview.getWebviewById('view/service/notice/checkedInList.html');
                if (checkedInList) {
                    checkedInList.close()
                }

                // 1、刷新FSE首页
                var indexFSE = plus.webview.getWebviewById('view/main/indexFSE.html');
                if (indexFSE) {
                    indexFSE.evalJS('getList("1")')
                }

                // 2、刷新客户签名页（标题：服务通知列表 signWorkReportList）
                var indexFSE = plus.webview.getWebviewById('signWorkReportList');
                if (indexFSE) {
                    indexFSE.evalJS('initData()')
                }


                app.jumpTo('/view/service/notice/signOutClose.html', 'view/service/notice/signOutClose.html', {
                    ServiceNoticeId: ServiceNoticeId,
                    serviceNo: serviceNo,
                    planId: planId,
                    serviceType: serviceType,
                    closeFlag:1
                })

                var self = plus.webview.currentWebview();
                setTimeout(function () {
                    self.close()
                    var signOutVisitAgain = plus.webview.getWebviewById('view/service/notice/signOutVisitAgain.html');
                    signOutVisitAgain&&signOutVisitAgain.close()
                },500)

            } else {
                if (data.data.data.status === '1') {
                    app.toast(data.msg)
                    var maintenanceReport = plus.webview.getWebviewById('view/service/report/maintenanceReport.html');
                    if (maintenanceReport) {
                        maintenanceReport.close()
                    }

                    var signOutAddReport = plus.webview.getWebviewById('view/service/notice/signOutAddReport.html');
                    if (signOutAddReport) {
                        signOutAddReport.close()
                    }

                    var signInAddReport = plus.webview.getWebviewById('view/service/notice/signInAddReport.html');
                    if (signInAddReport) {
                        signInAddReport.close()
                    }

                    var checkedInList = plus.webview.getWebviewById('view/service/notice/checkedInList.html');
                    if (checkedInList) {
                        checkedInList.close()
                    }

                    // 1、刷新FSE首页
                    var indexFSE = plus.webview.getWebviewById('view/main/indexFSE.html');
                    if (indexFSE) {
                        indexFSE.evalJS('getList("1")')
                    }

                    // 2、刷新客户签名页（标题：服务通知列表 signWorkReportList）
                    var indexFSE = plus.webview.getWebviewById('signWorkReportList');
                    if (indexFSE) {
                        indexFSE.evalJS('initData()')
                    }

                    // var closedList = plus.webview.getWebviewById('view/service/notice/closedList.html');
                    // if(closedList){
                    // 	closedList.evalJS('initData()')
                    // }
                    app.jumpTo('/view/service/notice/closedList.html', 'view/service/notice/closedList.html', {
                        ServiceNoticeId: ServiceNoticeId,
                        serviceNo: serviceNo,
                        planId: planId
                    })
                    // var closedList = plus.webview.getWebviewById('view/service/notice/signOutClose.html');
                    // if(closedList){
                    // 	closedList.evalJS('initData()')
                    // 	mui.back()
                    // }else{
                    // 	var self = plus.webview.currentWebview();
                    // 	var closedList1 = plus.webview.create('/view/service/notice/signOutClose.html','view/service/notice/signOutClose.html')
                    // 	closedList1.show()
                    // 	self.close()
                    // }
                    // app.jumpTo('/view/service/notice/signOutClose.html', 'view/service/notice/signOutClose.html', {
                    // 	ServiceNoticeId: ServiceNoticeId,
                    // 	serviceNo: serviceNo,
                    // 	planId: planId
                    // })
                    var self = plus.webview.currentWebview();
                    setTimeout(function () {
                        self.close()
                        var signOutVisitAgain = plus.webview.getWebviewById('view/service/notice/signOutVisitAgain.html');
                        signOutVisitAgain&&signOutVisitAgain.close()
                    },500)

                    // var closedList = plus.webview.getWebviewById('view/service/notice/closedList.html');
                    // if(closedList){
                    // 	closedList.evalJS('initData()')
                    // 	mui.back()
                    // }else{
                    // 	var self = plus.webview.currentWebview();
                    // 	var closedList1 = plus.webview.create('/view/service/notice/closedList.html','view/service/notice/closedList.html')
                    // 	closedList1.show()
                    // 	self.close()
                    // }
                    // app.jumpTo('/view/service/notice/closedList.html','view/service/notice/closedList.html')
                } else {
                    mui("#popover").popover('toggle', document.getElementById("div"));
                    app.closeWaiting()
                    app.toast(data.data.data.message)
                }
            }*/
        }, function (errorMsg) {
            app.closeWaiting()
            app.toast("关闭失败")
        });
    }

    function initData() {
        ajaxGet(BASE_URL + "cc/report/info/getAllCustomerSignList", {
            "serviceNo": serviceNo
        }, function (data) {
            app.closeWaiting()
            if (data.code === 200) {
                var str = '';
                var doneSum = 0;
                for (var c = 0; c < data.data.length; c++) {
                    var resServiceResult = data.data[c].serviceResult;
                    if (resServiceResult == '1') {
                        doneSum += 1;
                    }
                    var info = data.data[c];
                    var relServiceNo = data.data[c].relServiceNo;
                    var relServiceName
                    //报告类型（1=服务报告，2=Error Report，3=Hot Account Reprot，4=验收报告，5=安装质量报告，6=电话解决报告）
                    if (relServiceNo == '1') {
                        relServiceName = "现场服务报告";
                    } else if (relServiceNo == '2') {
                        relServiceName = "Error Report";
                    } else if (relServiceNo == '3') {
                        relServiceName = "Hot Account Reprot";
                    } else if (relServiceNo == '4') {
                        relServiceName = "安装验收报告";
                    } else if (relServiceNo == '5') {
                        relServiceName = "安装质量报告";
                    } else if (relServiceNo == '6') {
                        relServiceName = "电话解决报告";
                    }
                    str += '<div class="item">';
                    str += '<div class="bar">';
                    if (relServiceNo == '1' || relServiceNo == '4' || relServiceNo == '5') {
                        str += '<span class="yulan" onclick="preview(' + info.serviceNo + ',' + info.relServiceNo + ',' + info.id +
                            ',' + info.reportNo + ')">预览</span>';
                    }

                    // 对应传入的jumpToReportView参数 id, serviceNo, planId, relServiceNo, noticeId, realReportId, submitStatus
                    str += '<span class="number" onclick="jumpToReportView('
                        + info.id + ',' + info.serviceNo + ','
                        + info.planId + ',' + info.relServiceNo + ','
                        + info.noticeId + ',' + info.batchType + ','
                        + '1'+',\''+info.instrumentId+'\''
                        + ')">' + data.data[c].id + '<img src="../../../../images/icon_204.png" /></span>';
                    str += '</div>';
                    str += '<div class="type" onclick="jumpToReportView('
                        + info.id + ',' + info.serviceNo + ','
                        + info.planId + ',' + info.relServiceNo + ','
                        + info.noticeId + ',' + info.batchType + ','
                        + '1'+',\''+info.instrumentId+'\''
                        + ')">';
                    str += '<p><img src="../../../../images/icon_219.png"/><span class="fl lpl">FSE：</span><span>' + getNewStr(data.data[c].fseName) +
                        '</span></p>';
                    str += '<p><img src="../../../../images/icon_201.png"/><span class="fl lpl">客户名称：</span><span>' + getNewStr(data.data[c].customerName) +
                        '</span></p>';
                    str += '<p><img src="../../../../images/icon_203.png"/><span class="fl lpl">报告类型：</span><span>' + relServiceName +
                        '</span></p>';
                    var serviceResult = data.data[c].serviceResult
                    if (JS.IsNullOrEmpty(serviceResult)) {
                        serviceResult = "暂无"
                    } else if (serviceResult == '1') {
                        serviceResult = "完成"
                    } else if (serviceResult == '2') {
                        serviceResult = '未完成'
                    }
                    str += '<p><img src="../../../../images/icon_222.png"/><span class="lpl fl">服务结果：</span><span>' + serviceResult + '</span></p>';
                    /* str += '<p><img src="../../../../images/icon_217.png"/><span class="fl lpl">仪器型号：</span><span>' + getNewStr(data.data[c].instrumentNo) +
                        '</span></p>'; */
                    str += '</div>';
                    str += '</div>';
                }
                h('#itemBox').html(str);
                if (doneSum > 0) {
                    h('#khqm').show();
                } else {
                    h('#khqm').hide();
                }
            } else {
                app.toast(data.msg)
            }
        }, function (errorMsg) {
            app.closeWaiting()
            app.toast(errorMsg)
        });
    }

    // 查看报告(20200523 修复107) relServiceNo 报告类型（1=服务报告，2=Error Report，3=Hot Account Reprot，4=验收报告，5=安装质量报告，6=电话解决报告）
    function jumpTofFieldservice(id, serviceNo, planId, relServiceNo, noticeId, submitStatus) {
        app.showWaiting()
        ajaxGet(BASE_URL + 'cc/notice/getServiceNoticeDetailsAndReportCount', {
            serviceNo: serviceNo,
            serviceNoticeId: noticeId,
            planId: planId,
            enginnerId: app.getUser().enginnerId
        }, function (data) {
            app.closeWaiting()
            if (data.code === 200) {
                console.log(JSON.stringify(data))
                var city = data.data.serviceNotice.city
                var prov = data.data.serviceNotice.province
                var mdsign = data.data.serviceInstrument.mdsign
                var diviBu = data.data.serviceInstrument.diviBu
                var divi = diviBu.split("-")[0]
                var bu = diviBu.split("-")[1]
                var isWarranty = data.data.serviceNotice.isWarranty
                var serviceType = data.data.serviceNotice.serviceType
                var problem = data.data.serviceNotice.troubleDescription
                var subServiceType = data.data.serviceNotice.subServiceType

                //先判断是否有服务报告
                app.jumpTo("/view/service/report/fieldservice/report.html",
                    "view/service/report/fieldservice/report.html", {
                        serviceNo: serviceNo,
                        reportId: id,
                        planId: planId,
                        noticeId: noticeId,
                        isWarranty: isWarranty,
                        serviceType: serviceType,
                        subServiceType: subServiceType,
                        divi: divi,
                        bu: bu,
                        city: city,
                        prov: prov,
                        problem: problem,
                        mdsign: mdsign,
                        submitStatus: submitStatus
                    })

            } else {
                app.toast(data.msg)
            }
        }, function (errorMsg) {
            app.closeWaiting()
            app.toast(errorMsg)
        });
    }

    // 查看报告(20200523 修复107) relServiceNo 报告类型（1=服务报告，2=Error Report，3=Hot Account Reprot，4=验收报告，5=安装质量报告，6=电话解决报告）
    function jumpToReportView(id, serviceNo, planId, relServiceNo, noticeId, realReportId, submitStatus,instrumentNo) {
        if (relServiceNo == 1) {
            jumpTofFieldservice(id, serviceNo, planId, relServiceNo, noticeId, submitStatus);
        } else if (relServiceNo == 2) {
            app.jumpTo("/view/service/report/errorhot/errorReportEdit.html",
                "view/service/report/errorhot/errorReportEdit.html", {
                    serviceNo: serviceNo,
                    planId: planId,
                    noticeId: noticeId,
                    errId: realReportId,
                    submitStatus: submitStatus
                })
        } else if (relServiceNo == 3) {
            app.jumpTo("/view/service/report/errorhot/hotReportEdit.html",
                "view/service/report/errorhot/hotReportEdit.html", {
                    serviceNo: serviceNo,
                    planId: planId,
                    noticeId: noticeId,
                    hotId: realReportId,
                    submitStatus: submitStatus
                })
        } else if (relServiceNo == 4) {
            app.jumpTo("/view/service/report/acceptance/edit.html",
                "view/service/report/acceptance/edit.html", {
                    reportGuid: id,
                    submitStatus: submitStatus
                })
        } else if (relServiceNo == 5) {
            app.jumpTo("/view/service/report/installationquality/add.html",
                "view/service/report/installationquality/add.html", {
                    serviceNo: serviceNo,
                    planId: planId,
                    ServiceNoticeId: noticeId,
                    iqrId: realReportId,
                    submitStatus: submitStatus,
                    instrumentNo:instrumentNo
                })
        } else if (relServiceNo == 6) {
            app.jumpTo("/view/service/report/phone/edit.html",
                "view/service/report/phone/edit.html", {
                    reportGuid: id,
                    submitStatus: submitStatus
                })
        }
    }

    function getNewStr(str) {
        if (JS.IsNullOrEmpty(str)) {
            return '';
        }
        return str;
    }

    //报告类型（1=服务报告，2=Error Report，3=Hot Account Reprot，4=验收报告，5=安装质量报告，6=电话解决报告）
    function preview(serviceNo, relServiceNo, reportId, reportNo) {

        if (relServiceNo == '1') {
            app.jumpTo('/view/service/report/preview/fuwunr.html', 'view/service/report/preview/fuwunr.html', {
                serviceNo,
                reportId,
                reportNo
            })
        }

        if (relServiceNo == '5') {
            app.jumpTo('/view/service/report/preview/baogaonr.html', 'view/service/report/preview/baogaonr.html', {
                serviceNo,
                reportId,
                reportNo
            })
        }

        if (relServiceNo == '4') {
            app.jumpTo('/view/service/report/preview/yanshounr.html', 'view/service/report/preview/yanshounr.html', {
                serviceNo,
                reportId,
                reportNo
            })
        }

    }

    function findSignInTime() {
        //根据planId 获取签到时间
        ajaxGet(BASE_URL + "cc/PlanDetails/getDetailsById", {
            "id": planId
        }, function (data) {
            console.log(JSON.stringify(data))
            if (data.code == 200) {
                signInTime = data.data.signInTime
            } else {
                app.toast('操作失败');
            }
        }, function (errorMsg) {
            app.toast('操作失败');
            console.log(JSON.stringify(errorMsg))
        });
    }

    h("#dianji").tap(function(){
        app.jumpTo("/view/workArea/service/serveDetails.html", "view/workArea/service/serveDetails.html", {
            "serviceNo": serviceNo,
            "enginnerId": app.getUser().enginnerId
        })
    })
</script>
<!-- js代码 end -->
</body>
</html>
